import { Form, Input, InputNumber, Radio, Select, Space } from "antd"
import lessModule from "./index.module.less"
import HomePage_ModalComponent_HeaderNormalComponent from "../../../../../../component/modal/component/headerNormal"
import HomePage_ModalComponent_NormalFooterComponent from "../../../../../../component/modal/component/normalFooter"
import { Fragment, useEffect, useState } from "react"
import { $eventBus, $EventBus_off, $EventBus_on } from "../../../../../../../../common/utils"
import HomePage_WarningThresholdFormComponent from "../../../../../../component/warningThresholdForm"
import HomePage_ChannelCoefficientComponent from "../../../../../../component/channelCoefficient"
import { RadioChangeEvent } from "antd/lib"
import HomePage_DebuggingAndTestingPage_PortableDeviceAccessPage_SelectSubstationComponent from "../selectSubstation"


// 主页-调试测试页面-便携设备接入页面-新增弹窗组件
interface homePageDebuggingAndTestingPagePortableDeviceAccessPageAddModalComponentInterface {
    modalData: object
    change_cancel: Function
}
const HomePage_DebuggingAndTestingPage_PortableDeviceAccessPage_AddModalComponent: React.FC<homePageDebuggingAndTestingPagePortableDeviceAccessPageAddModalComponentInterface> = (props) => {
   
   
    const deviceList = ["主变（便携装置）", "线路（便携装置）"]
    const [deviceType, setDeviceType] = useState<string>(deviceList[0])
    const [warningThresholdFormData, setWarningThresholdFormData] = useState<object>({})
    const [channelCoefficientFormData, setChannelCoefficientFormData] = useState<object>({})

    const change_radioGroup = (data: RadioChangeEvent) => {
        setDeviceType(data.target.value)
    }
    // 广播函数数据
    const eventBusFuncData = {
        submitOperation:(data) => {
            // addressForm.validateFields().then((data) => {
            //     console.log(data);

            // })
        },
        homePageDebuggingAndTestingPagePortableDeviceAccessPageSelectSubstationComponentMailingAddressComponent_data:(data) => {
        
        }
    }
    useEffect(() => {
        $EventBus_on(eventBusFuncData)
        return () => {
            $EventBus_off(eventBusFuncData)
        }
    }, [])
    return (
        <div className={lessModule["homePageDebuggingAndTestingPagePortableDeviceAccessPageAddModalComponent"]}>
            <HomePage_ModalComponent_HeaderNormalComponent name="新增便携设备" padding="15px 24px" change_cancel={props.change_cancel} />
            <main className={lessModule["homePageDebuggingAndTestingPagePortableDeviceAccessPageAddModalComponent-main"]}>
                <Space direction="vertical" size={24}>
                    <Space direction="vertical" size={16}>
                        <div className={lessModule["homePageDebuggingAndTestingPagePortableDeviceAccessPageAddModalComponent-main__title"]}>
                            <span className="homePage-required">*</span>
                            <span>选择设备类型</span>
                        </div>
                        <Radio.Group onChange={change_radioGroup} value={deviceType}>
                            {
                                deviceList.map((item, idx) => (
                                    <Fragment key={`radioItem${idx}`}>
                                        <Radio value={item} >{item}</Radio>
                                    </Fragment>

                                ))
                            }
                        </Radio.Group>
                    </Space>
                    <HomePage_DebuggingAndTestingPage_PortableDeviceAccessPage_SelectSubstationComponent type={deviceType}/>
                </Space>

                {/* <HomePage_WarningThresholdFormComponent change_formData={setWarningThresholdFormData} /> */}
                <HomePage_ChannelCoefficientComponent change_formData={setChannelCoefficientFormData} />
            </main>
            <HomePage_ModalComponent_NormalFooterComponent change_cancel={props.change_cancel} />
        </div>
    )
}
export default HomePage_DebuggingAndTestingPage_PortableDeviceAccessPage_AddModalComponent